package crazy.java.cha09;

import java.util.Collection;
import java.util.HashSet;
import java.util.function.Predicate;

/**
 * @author futao
 * Created on 2017/12/1 - 15:52.
 */
public class Pre {
    public static int calAll(Collection c, Predicate p) {
        int total = 0;
        for (Object o : c) {
            if (p.test(o)) {
                total++;
            }
        }
        return total;
    }

    public static void main(String[] args) {
        String a="6666";
        Collection c = new HashSet();
        c.add(a);
        c.add("666");
        c.add("999");
        c.add("555");
        System.out.println(c.size());
        System.out.println(calAll(c, it -> ((String) it).contains("666")));
        System.out.println(calAll(c, it -> (it.toString().contains("555"))));
    }
}
